Sickle - SECCON 2023
#SECCON_2023 #pickle
https://github.com/trailofbits/fickling を用いてpayloadを解析すると、概ね以下のコードのような処理が行われていることがわかった。
code:python
flag = input("FLAG> ").encode()
if len(flag) != 64 or not all(c <= 127 for c in flag):
exit()
flag_parts = [int.from_bytes(flagi*8:i*8+8, 'little') for i in range(8)]
enc = []
key = 1244422970072434993
for flag_part in flag_parts:
key = pow(flag_part ^ key, 65537, 18446744073709551557)
enc.append(key)
if enc == 8215359690687096682, 1862662588367509514, 8350772864914849965, 11616510986494699232, 3711648467207374797, 9722127090168848805, 16780197523811627561, 18138828537077112905:
print("Congratulations!!")
else:
print("Nope")
powとxorを組み合わせた暗号アルゴリズムが使われており、encから逆向きに計算することでflagが得られた。
code:python
enc = 8215359690687096682, 1862662588367509514, 8350772864914849965, 11616510986494699232, 3711648467207374797, 9722127090168848805, 16780197523811627561, 18138828537077112905
p = 18446744073709551557
e = 65537
d = pow(e, -1, p - 1)
def decode(c, key):
return pow(c, d, p) ^ key
flag = ''
key = 1244422970072434993
for i in range(len(enc)):
flag += int.to_bytes(decode(enci, key), 8, 'little').decode()
key = enci
print(flag)